package com.ray.test.util;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author bo shen
 * @Description: 方法执行工具类
 * @Class: MethodRunUtil
 * @Package com.ray.test.util
 * @date 2020/2/12 23:39
 * @company <p>杭州传化陆鲸科技有限公司</p>
 * @updateRecord time(修改时间)  author(修改人)   desc(修改内容)
 */
public class MethodRunUtil {

    public  static Object invoke(Method method, Object target, Object[] params) throws InvocationTargetException, IllegalAccessException {
        if (params == null) {
            return method.invoke(target, null);
        }

        if (params.length == 1) {
            return method.invoke(target, (Object) params[0]);
        }

        return method.invoke(target, params);
    }
}
